import { patientCardTypeBase, genderBase, marriageBase, patientRelationBase } from '@/config/lvtongConfig/constant';
import { phoneValidator } from '@/utils/validator';

export const patientInfos = function () {
  const patientInfo = [
    {
      label: '姓名',
      code: 'patientName',
      placeholder: '请输入姓名',
      componentId: 'field-item-input',
      required: true,
    },
    {
      label: '证件类型',
      code: 'patientCardType',
      placeholder: '请选择证件类型',
      componentId: 'field-item-picker',
      columns: patientCardTypeBase,
      required: true,
    },
    {
      label: '证件号码',
      code: 'patientCardNo',
      placeholder: '请输入证件号码',
      componentId: 'field-item-input',
      required: true,
    },
    {
      label: '联系电话',
      code: 'patientMobile',
      placeholder: '请输入电话号码',
      componentId: 'field-item-input',
      required: true,
      rules: [{ validator: phoneValidator, message: '请输入正确的电话号码' }],
    },
    {
      label: '性别',
      code: 'patientGender',
      placeholder: '请选择性别',
      componentId: 'field-item-radio',
      columns: genderBase,
      required: true,
    },
    {
      label: '出生日期',
      code: 'patientBirthdate',
      placeholder: '请选择出生日期',
      componentId: 'field-item-date',
      minDate: new Date(1950, 0, 1),
      maxDate: new Date(),
      current: new Date(),
      required: true,
    },
    {
      label: '婚姻状况',
      code: 'patientMarital',
      placeholder: '请选择婚姻状况',
      componentId: 'field-item-radio',
      columns: marriageBase,
      required: true,
    },
    {
      label: 'ta是你的',
      code: 'patientRelation',
      placeholder: '请选择关系',
      componentId: 'field-item-picker',
      columns: patientRelationBase,
      required: true,
    },
    {
      label: '医保卡号',
      code: 'medicareCardNo',
      placeholder: '请输入医保卡号',
      componentId: 'field-item-input',
      unnecessary: true,
      required: false,
    },
    {
      label: '医保手机',
      code: 'medicareMobile',
      placeholder: '请输入医保卡绑定的手机号码',
      componentId: 'field-item-input',
      unnecessary: true,
      required: false,
    },
  ];
  return patientInfo.map((item) => {
    const rules = [{ required: item.required, message: item.placeholder }];
    if (item.rules) {
      rules.push(...item.rules);
    }
    return {
      ...item,
      value: '',
      rules,
    };
  });
};

export const buttonGroup = [
  {
    buttonText: '删除',
    funcName: 'deleteUser',
    nativeType: 'button',
    plain: true,
    show: ['edit'],
  },
  {
    buttonText: '下一步',
    nativeType: 'submit',
    show: ['chose'],
  },
  {
    buttonText: '保存',
    funcName: 'addpatient',
    nativeType: 'button',
    show: ['edit', 'add'],
  },
];
